package com.commute.data;
import java.util.LinkedList;



public class DataStructure {
	public LinkedList<Stop> stops;
	public LinkedList<Route> routes;
	
	public DataStructure(){
		stops = new LinkedList<Stop>();
		routes = new LinkedList<Route>();
		stopMaker();
		routeMaker();
		stopAdder();
		
//		for (Route r : routes) {
//			System.out.println(r.stops.size());
//		}
		
		for (Route r : routes) {
			combine(r);
		}
	}
	
	
	private void stopMaker(){															// LAT 			LON
		Stop stop12 = new Stop("Porsö Centrum", 12, 65.619477, 22.145288);				//65.619477	22.145288
		stops.add(stop12);
		Stop stop15 = new Stop("Proffesors vägen", 15, 65.616067, 22.148098);			//65.616067	22.148098
		stops.add(stop15);
		Stop stop13 = new Stop("Ericsson", 13, 65.620513, 22.142434);					//65.620513	22.142434
		stops.add(stop13);
		Stop stop11 = new Stop("Alpha huset", 11, 65.61666, 22.13988);					//65.61666	22.13988
		stops.add(stop11);
		Stop stop14 = new Stop("Kårhusvägen", 14, 65.618538, 22.133314);				//65.618538	22.133314
		stops.add(stop14);
		Stop stop19 = new Stop("Smedjegatan", 19, 65.583658, 22.152375);				//65.583658	22.152375
		stops.add(stop19);
		Stop stop1 = new Stop("Bäverstigen", 1, 65.586155,	22.260894); 				//	65.586155	22.260894
		stops.add(stop1);
	}
	
	private void routeMaker(){
		Route route21 = new Route("FYRAN", 21);
		
		routes.add(route21);
		
		Route route22 = new Route("FEMMAN", 22);
		routes.add(route22);
		Route route23 = new Route("ÅTTAN", 23);
		routes.add(route23);
		
		Route route1 = new Route("ETTAN", 1);
		routes.add(route1);
		
	}
	
	private void stopAdder(){
		for (Route r : routes) {
			if(r.id ==21){						//FYRAN
				r.stops.add(stops.get(0));
				r.stops.add(stops.get(3));
				r.stops.add(stops.get(5));
			}
			if(r.id ==22){						//FEMMAN
				r.stops.add(stops.get(0));
				r.stops.add(stops.get(1));
				r.stops.add(stops.get(2));
				r.stops.add(stops.get(4));
				r.stops.add(stops.get(5));
				r.stops.add(stops.get(6));
				
			}
			if(r.id ==23){						//ÅTTAN
				r.stops.add(stops.get(0));
				r.stops.add(stops.get(1));
				r.stops.add(stops.get(5));
			}
			if(r.id==1){						//ETTAN
				r.stops.add(stops.get(5));		
				r.stops.add(stops.get(6));
			}
		}
	}
	
	
	
	private void combine(Route r){
		for (Stop s : stops) {
			if(r.stops.contains(s)){
				s.routes.add(r.id);
			}
		}
	}
	
	
}
